package edu.ptu.acl.dto.param;

import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@Data
public class RoleParam {

    @Min(value = 10000000000000000L,message = "id不规范" ,groups = Update.class)
    private Long id;

    /**
     * 角色名称
     */
    @NotBlank(message = "用户名不能为空",groups = {Update.class, Save.class})
    @Length(min = 1,max = 20,message = "用户名长度必须是1-20个字符",groups = {Update.class, Save.class})
    private String name;

    /**
     * 描述
     */
    private String remark;

    /**
     * 模块id
     */
    @NotNull(message = "上级模块不能为空",groups = {Update.class, Save.class})
    private Long parentId;

    /**
     * 状态1：正常，0：冻结状态
     */
    @NotBlank(message = "状态不能为空",groups = {Update.class, Save.class})
    @Pattern(regexp = "[10]",message = "状态异常",groups = {Update.class, Save.class})
    private String status;

    @NotNull(message = "乐观锁版本不能为空",groups = {Update.class})
    private Integer version;

    /**
     * 保存的时候校验分组
     */
    public interface Save {
    }

    /**
     * 更新的时候校验分组
     */
    public interface Update {
    }
}
